Repository navigation
fix(spec,i18n): an object's embedded listViews are served translated from the _views keys the extractor writes (#21006) - #21072
Conversation
…ws from the _views keys the extractor writes An object document's embedded `listViews` are now translated through the same `objects.<object>._views.<key>` lookup a served view document uses (label, description, bulk-action copy), keyed by the record key the i18n extractor's `pushViewEntries` writes. A published override still beats the packaged catalog, judged per view against the packaged object's own `listViews` by the existing `valueOverridesPackagedBase` comparison. Claude-Session: https://claude.ai/code/session_017VaLJnYwhPsanVCe9dMCJU Co-authored-by: Claude <noreply@anthropic.com>
…an update def, as the schema requires Claude-Session: https://claude.ai/code/session_017VaLJnYwhPsanVCe9dMCJU Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017VaLJnYwhPsanVCe9dMCJU Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 10 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 1 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 137 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 188246744e59e986b53180824d6a9529965f6b94 && git checkout 188246744e59e986b53180824d6a9529965f6b94
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 5dbeb7d7b7e1deb7a64bd3178d2faada69c3097c 402ab32f5d8eb1969eecd3032547a58575561007 && git checkout -B drift-repro 5dbeb7d7b7e1deb7a64bd3178d2faada69c3097c && git merge --no-ff 402ab32f5d8eb1969eecd3032547a58575561007
node scripts/docs-audit/affected-docs.mjs --json 5dbeb7d7b7e1deb7a64bd3178d2faada69c3097c
|
Contract reviewServed-tier: Inputs read: card #21006 (body and all three comments: triage 5923336850, claim 5923678939, os-dev-report 5924833736), PR #21072 (body, its three-file list, the net diff of +466/-21 against the merge base ① Derived judgments
② Semver level
③ Boundary flags
Check-runs on the head, as readCompleted, success (22): Auto Label, Build Core, Check Changeset, Check Documentation Links, Check PR Size, Dogfood Regression Gate, Dogfood Regression Gate (1/3), (2/3), (3/3), Dogfood Verify CLI, Flag docs affected by code changes, Governed Surface Queue Guard, No other open PR may claim the same issue, No other open PR may claim the same single-writer path, Part-of PR must not also close its card, Spec property liveness, Test Core (4/6), The card this PR closes must claim this branch, Type Check · consumer gates, Type Check · debt ledger, Type Check · source gates, filter. Implemented-by: VERDICT: PASS Generated by Claude Code |
… views (objectui#11336) (objectstack-ai#11620) Fixes objectstack-ai#11336 Clause-②: no ## What changed `@objectstack/spec` 17.6.0 (objectstack-ai/objectstack#21072, `c27404f0a9`) translates the `listViews` an object document embeds on the server, from `objects.OBJECT._views.KEY` and with a published edit kept over the packaged catalog. The console still ran its own catalog over those labels a second time. This PR counts such a view as served, so the switcher tab and the breadcrumb draw its label as given. - `packages/app-shell/src/hooks/useServedViewItems.ts` - `isServedView(served, objectName, viewId)` answers true for a `/meta/view` document named `viewId`, as before. It now also answers true when `viewId` is a key of the served `objectName` document's own `listViews`. - That document is read before the merge, from `useMetadata().getItemsByType('object')`. The merged `listViews` the label sites hold mixes the document's own entries with view documents and a container's expansion, and only the document's own entries were translated by `translateObject`. - Only the canonical `listViews` key is read, and the entry must be a record. The server translates no other spelling, so a view a stored document embeds under the legacy `list_views` keeps the bundle. The probe below measures this. - `useServedViewItems()` returns both reads as one record. It is held in a module-level `WeakMap` keyed on the two cache arrays, so its identity depends on the payloads, never on a React memo (AGENTS.md objectstack-ai#10). - The docblock bullet "The server's `translateObject` does not translate those" is corrected. - `packages/app-shell/src/views/ObjectView.tsx` (`viewTabLabel`, `viewOriginLabel`) and `packages/app-shell/src/layout/AppHeader.tsx` (the crumb) now pass the object name to the predicate. Their comments now name both reads. - Tests: - The two existing objectstack-ai#11295 suites now serve the `/meta/object` document as well, and their stale prose is corrected. - The old "object-embedded view is named by the bundle" control now uses a view only the client derives (a stack container's expansion). - New objectui#11336 cells cover the tab and the crumb. - A unit file pins the predicate's edges and the hook's identity. - `.changeset/11336-served-embedded-listviews.md`: `@object-ui/app-shell` patch. No export, prop, type member or i18n key is added to any package entry. `useServedViewItems` and `isServedView` are not reachable from `@object-ui/app-shell`'s entry: `exports` maps only `.` and `./styles.css`, and both names are absent from `src/index.ts` and `src/hooks/index.ts`. The control `useRecentItems` has 2 hits in `src/index.ts`. ## Premise check (measured on `origin/main`, not taken from the card) - **The label sites read the served object.** `ObjectView` and `AppHeader` receive `objects` from `useMetadata().objects` (`AppContent`). That getter is `mergeViewsIntoObjects(readType('object'), readType('view'))`. `getItemsByType('object')` returns the cache's own `/meta/object` items, mutated only by `normalizeSchemaReferenceKeys`, which touches field reference keys. The merge copies the served document's own `listViews` entries under their record keys, and those keys win collisions. So an embedded tab's id is the key the served document carries. - **The server translates them.** A probe ran against the installed `@objectstack/spec` 17.6.0 (`system.translateObject`, locale `zh-CN`, a catalog with `objects.sys_account._views.mine.label`): | Case | Served label | | --- | --- | | `listViews.mine` | `我的链接` | | sibling `other`, no catalog entry | `Other` | | `mine` carrying an org edit (`Links I own`), with `packagedBase` | `Links I own` (the catalog loses) | | legacy `list_views.mine` | `My Links` (untranslated) | - **Not translated by any server:** a stack container's expansion. `translateView` does not walk a container's nested `listViews`, so that kind still goes through the bundle. ## Evidence (head `0a2c2af`) - `pnpm exec vitest run` on the three touched test files (repo-root spelling), before the merge at `5b212d6`: `Test Files 3 passed (3)`, `Tests 35 passed (35)`. The full-package run below covers them again on the merged head. - **Reverse verification**, run after commit through `ablation-replace.mjs` (anchor hit 1 time; blob changed, then restored equal to HEAD; `git diff HEAD` empty afterwards). The object-document branch was cut (`if (!objectName) return false;` became `return false;`), and the predicted cells went red: `Tests 7 failed | 28 passed (35)`. - Red: the two ObjectView "published edit the object read served" cells, the two AppHeader cells, and three unit cells (embedded key answers; key answers only under its object; identity record answers after a refetch). - Green on both sides: the zh-CN served-string cells (the catalog says the same thing), the no-catalogue and container controls, and every objectstack-ai#11295 cell. - `pnpm --filter @object-ui/app-shell type-check` (`tsc --noEmit && tsc -p tsconfig.test.json`): exit 0 on the merged head, after the `@object-ui/app-shell^...` dependency closure was built. `tsc -p tsconfig.test.json --listFiles` lists all three touched test files. - `pnpm exec vitest run packages/app-shell/` on the merged head: `Test Files 1000 passed | 1 skipped (1001)`, `Tests 9930 passed | 9 skipped (9939)`, exit 0. The run held the shared verify lock; wall-clock figures are omitted because the box is shared. - ESLint on the six touched source and test files: 0 errors. Per-file warning counts equal `fd060f0767`'s (ObjectView 174, AppHeader 22, the two objectstack-ai#11295 suites 3 and 17, the hook 0). The new unit file has 0 warnings. - Root gates run locally, each exit 0: `check-changeset-presence`, `check-changeset-no-major`, `check:changeset-claims` (with the changeset committed), `check:pending-changeset-literals`, `check:new-line-citations` (0 new), `check:control-bytes`, `check:vi-mock-specifiers`, `check:vi-mock-inherit`, `check:vi-mock-override-shape`, `check:test-path-roots`, `check:unreferenced-sources`. CI runs the rest. ## Acceptance notes - **Older servers.** A console with this change, talking to a server whose spec predates `c27404f0a9` (17.0 to 17.5), draws embedded views' labels as authored. Today the console's second pass translates them. I found no version gate in app-shell: the only server-capability signals it reads are the runtime config's `features.*` flags, and none of them says "embedded listViews are served translated". The CLI-shipped pairing is unaffected, because `@objectstack/console` is built at the objectui SHA pinned per framework release. The exposed pairing is `@object-ui/console` run on its own cadence against an older 17.x server. No gate is added here; the question is in the report. - Observation, out of this card's surface and not filed: `useNavTargetLabel` (nav-entry labels) passes a view's label through `viewLabel` without asking `isServedView`, for both channels. No reproduction was run, and no carrier is known. - `objectui#11303` kept the console path for embedded `listViews` because the server did not translate them then. That reason is gone with 17.6.0, which `pnpm-lock.yaml` resolves. Implemented by the dispatched `os-dev` agent, session `https://claude.ai/code/session_015W8GBu6sBiqus2L2xjMsAL`. --- _Generated by [Claude Code](https://claude.ai/code/session_015W8GBu6sBiqus2L2xjMsAL)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
Fixes #21006
Clause-②: no
What changed
translateObject(packages/spec/src/system/i18n-resolver.ts) now translates each view in an object document's embeddedlistViews. It overlays the view'slabel, itsdescriptionand itsbulkActionDefs[]copy (deflabel/confirmText/confirmLabel, paramlabel/help/placeholder). These are the same stringstranslateViewoverlays on a served view document.objects.OBJECT._views.VIEW.*, where VIEW is the record key underlistViews.os i18n extractwrites exactly that: itsobj.listViewsloop handspushViewEntriesthe record key (packages/cli/src/utils/i18n-extract.ts). The record key is already bare, soviewTranslationKey, which strips a served view'sOBJECT.prefix, is not involved, and the view's own optionalnameis never read.resolveViewLabel/resolveViewDescriptionand the embedded channel now share one private lookup (lookupViewText) of_views.VIEW.label/.description. No second key function exists.translateBulkActionDefs, readingview.bulkActionDefs. That is the authored address the extractor reads. A served view document nests the same list underconfig, andtranslateViewkeeps reading it there.translateViewapplies it (the rule from metadata: a published org overlay on the built-in system_overview dashboard is never served — the plain read and the rendered board keep the shipped body while ?layers=true reports the overlay as effective #20680 / rest: the /meta dashboard item and list reads pass no packaged base to translateDashboard, so a published org overlay on a translated dashboard keeps the shipped widget title — per-layer child of #20680 #20730). Each string is judged by the existingvalueOverridesPackagedBaseagainst the same view in the packaged object'slistViews. That packaged object is thepackagedBasethe REST read gate already supplies for objects (getPackagedObjectBase). A view the packaged base does not carry counts as authored. With no base supplied, the catalog applies.emptyStateis not translated server-side on either channel.translateViewnever translated it, and the extractor's docblock names the client as its only reader.ObjectLikegains an optionallistViewsmember, typed as a string-keyedRecordofunknown. It is a TS-only input shape: no export is added and no generated artefact moves. The only code that builds anObjectLikein this repo (service-analytics'{ name, fields }) still type-checks. The reverse verification is below.The change lands where the claim said it would.
translateObjectproduces the served labels, and the extractor is untouched.Measured
H1, the key shape. An embedded
listViewsentry is anObjectListViewSchema(data/object.zod.ts). Its copy-bearing keys that the extractor emits under_views.VIEWarelabel,description,emptyState.title/.messageandbulkActionDefs[].*. All of them sit under the key shape the resolver already reads. Nothing needed a new key.H2, the override order.
translateViewandtranslateDashboardboth judge withvalueOverridesPackagedBaseagainstpackagedBase(#20731 / #20680). The embedded channel uses the same predicate and the same three edges: no base means the catalog applies, a non-string label is never an override, and an edit back to the shipped string is a no-op.H3, the door.
GET /api/v1/meta/objectgoesmeta-item-read-gate.tstranslateMetaDocument/translateMetaList, thentranslateMetadataDocument('object'), thentranslateObject, withpackagedBasefromgetPackagedObjectBase.metadata-protocol/src/protocol.tsnamestranslateObjectonly in a docblock and does not call it. I measured the door once through the REST route handlers. The protocol double served the REALSysAccount(@objectstack/platform-objects/identity),getPackagedObjectBaseanswered the same object, and the i18n service served the REAL shippeden/zhCNbundles (@objectstack/platform-objects/apps). It ran as a scratch test that is not committed.2f2fa11d7)label(object)身份链接身份链接listViews.mine.labelMy Links我的链接listViews.by_provider.labelBy Provider按提供方listViews.mine.labelMy Links我的链接mine=My Links (edited-21006), itemMy Links (edited-21006)My Links (edited-21006)(the overlay wins)by_providerBy Provider按提供方en, itemlistViews.mine.labelMy LinksMy LinksThe CLI's coverage still counts the same keys.
i18n-coveragetakes its key set from the extractor'scollectExpectedEntries, which this PR does not touch.pnpm check:i18n-coverageexited 0 and the CLI's i18n unit tests passed (below), so extract and serve now agree.Tests
New file
packages/spec/src/system/i18n-resolver.object-list-views.test.ts, 21 cases. Thesys_accountfixture is transcribed fromidentity/sys-account.object.ts, with its_viewsleaves taken verbatim from the shippeden/zh-CNbundles. Every view is parsed byObjectListViewSchemaand the bundle byTranslationBundleSchema.sys_account'sminetab is served我的链接in zh-CN, and every sibling tab is translated too._viewsgets the samelistViewsreference back; no bundle gets the same reference back; an object with nolistViewsgains none.name. BCP-47 base-language matching applies, and a default-locale request does not walk the fallback chain.descriptionand bulk-action copy are translated from the embedded view's own address.en, each tab is judged separately, no base means the catalog applies, a reset restores the translation, and the edge cases hold (edit back to the shipped string, inline map). A tab the base does not ship keeps its label. The object-scalar rule and the tab rule are independent.translateMetadataDocument('object')reaches the change.Reverse verification. The fix was committed first. Each mutation went through
scripts/ablation-replace.mjs, which reported the anchor hit, the blob moved, and then restored to blob == HEAD withgit diff HEADempty.translateObjectListViews(...)call withdoc.listViews. Result: 15 failed / 6 passed of 21. The 6 that passed are the controls and the edited-wins cases, which pass when nothing is translated.valueOverridesPackagedBase(...)withfalse. Result: 5 failed / 16 passed. All 5 failures are override cases.listViews: 5into service-analytics'ObjectLikeliteral.tscansweredsrc/plugin.ts(1056,61): error TS2322, saying typenumberis not assignable to the string-keyedRecordofunknown. That is the rebuilt.d.ts; the old one would have answered an excess-property error. Restored.Local verification (HEAD
402ab32f5)The spec closure (①) is empty, because
packages/spechas no workspace dependencies. Consumer closures were built withturbo run build --filter='@objectstack/rest^...'and with the@objectstack/cli^.../@objectstack/plugin-approvals^...packages that were not built yet.pnpm --filter @objectstack/spec build→ 0.check:generated→✓ All 15 generated artifacts are up to date.pnpm --filter @objectstack/spec typecheck→ 0 (check:test-typecheck: OK).vitest run src/system→ 49 files / 1720 passed.@objectstack/rest, the fivemeta-*i18n*tests: 5 files / 96 passed.@objectstack/metadata-protocol, full suite: 195 passed / 3 skipped files, 2896 tests passed.@objectstack/cli,--project unittest/i18n-+test/platform-page-i18n-parity: 22 files / 292 passed. The integration tier is declared to CI.@objectstack/service-analytics, full suite: 150 files / 3458 passed. Itstypecheck→ 0.@objectstack/platform-objects, full suite: 59 files / 948 passed.@objectstack/plugin-approvals,src/translations: 3 files / 11 passed.dispatch-gates.mjs --commandsover this diff (84 families) pluscheck:i18n,check:i18n-coverageandcheck:i18n-walk-parity: 83 of 84 ran and exited 0.check:dual-build-cjs-loadsfirst answered PREREQUISITE NOT MET (exit 3) and exited 0 after the missing packages were built.--ranreconciliation: 84 derived, 83 run, 0 NOT-MEASURED, 1 UNRUN.check:type-check-debt. Reason:--re-measureruns tsc over the whole workspace and was killed twice at the 570 s foreground budget; it has no narrowing option. CI'sLint & Repo Gatesowns it. The type-check this diff owes was measured: spec and service-analyticstypecheckboth 0.eslint --no-inline-config --format jsonover the two changed TS files: 2 files, 0 errors, 0 warnings. Both files are in the population, byeslint --print-config.eslint.config.mjsenables no type-aware linting (noparserOptions.project), so this diff cannot move a verdict on any untouched file. The fullpnpm lintrun belongs to CI.Acceptance notes
pushViewEntriesdocblock (packages/cli/src/utils/i18n-extract.ts) namestranslateViewas the server-side reader of_views.VIEW.label/.description. After this PR,translateObjectis a second server-side reader, for the object-nested channel. The docblock lags in a file outside this card's surface. Noted, not filed._views.VIEW.emptyState.*is still read client-side only, on both channels. That is unchanged and is stated as design in the extractor's docblock.2f2fa11d7and was not merged withmainbefore opening.origin/mainis 21 commits ahead. None of those commits touchesi18n-resolver.ts, its tests, the REST meta read gate, the extractor or the platform catalogs. Theirui/view.zod.tschange is docblock-only, and theirrest-server.tschange is outside the translation path. PR CI runs on the merge ref.objectui follow-up (not in this PR)
objectui's
packages/app-shell/src/hooks/useServedViewItems.tsdocuments the/meta/object-embedded views as untranslated by the server. Once this lands,isServedViewshould also answer true for a view id that is a key of the served/meta/objectdocument'slistViews, read from the pre-mergeuseMetadata().getItemsByType('object'). ThenviewTabLabel(ObjectView.tsx) and theAppHeadercrumb draw those labels as given instead of a secondviewLabelpass, in which the bundle would win an edit back. The seat files that child after this lands.Generated by Claude Code